% To be compiled by XeLaTeX, preferably under TeX Live.
% LaTeX source for ``Yanqi Lake Lectures on Algebra'' Part III.
% Copyright 2019  李文威 (Wen-Wei Li).
% Permission is granted to copy, distribute and/or modify this
% document under the terms of the Creative Commons
% Attribution-NonCommercial 4.0 International (CC BY-NC 4.0)
% https://creativecommons.org/licenses/by-nc/4.0/

% To be included
\chapter{Integral dependence, Nullstellensatz and flatness}

The materials below largely come from \cite[\S 4]{Eis95}, \cite[V.4]{AK70} and \cite[\S\S 5--6]{Mat80}. In what follows, any ring $R$ and the $R$-algebras are assumed to be commutative. For elements $a,b, \ldots$ in an $R$-algebra, denote by $R[a,b, \ldots]$ the $R$-subalgebra generated by them.

\section{Integral extensions}
Consider an $R$-algebra $A$. Recall that to give an $R$-algebra $A$ is the same as to give a ring homomorphism $\varphi: R \to A$. We shall switch freely between algebra and homomorphisms, omitting $\varphi$ if necessary. In many concrete circumstances $R$ is simply a subring of $A$.

\begin{definition}\index{integrality}
	An element $x \in A$ is said to be \emph{integral} over $R$ if there exists a monic polynomial $P(X) = X^n + a_{n-1} X^{n-1} + \cdots + a_0 \in R[X]$ (with $n \geq 1$) such that $P(x)=0$. If every $x \in A$ is integral over $R$, we say $A$ is integral over $R$.
\end{definition}
Note that elements from $R$ are trivially integral: take $P(X)$ with $n=1$. In the case $A = \CC$ and $R = \Z$, we recover the notion of \emph{algebraic integers}.

When $R$ is a field, we usually say \emph{algebraic} instead of \emph{integral}. The monic assumption on $P$ is crucial when $R$ is not a field, as illustrated by the following proof.

\begin{proposition}
	An element $x \in A$ is integral over $R$ if and only if there exists an $R$-submodule $M \subset A$ such that
	\begin{compactitem}
		\item $M$ is a finitely generated $R$-module;
		\item $xM \subset M$, thus $M$ is an $R[x]$-module;
		\item $M$ is a faithful $R[x]$-module i.e. $\mathrm{ann}_{R[x]}(M) = \{0\}$, and
	\end{compactitem}
	If $x$ is integral, $M := R[x]$ satisfies the conditions listed above.
\end{proposition}
\begin{proof}
	This is a familiar application of Cayley-Hamilton theorem, which we recall below. If $x$ is integral, say $x^n + a_{n-1} x^{n-1} + \cdots + a_0 = 0$, a straightforward induction shows that
	\[ R[x] = \sum_{i=0}^{n-1} Rx^i. \]
	In particular we may take $M := R[x]$ to be the required submodule, which is faithful as $1 \in R[x]$. Conversely, given a submodule $M$ as above, with generators $x_1, \ldots, x_m$, we make $M$ into an $R[X]$-module by letting the variable $X$ act as multiplication by $x$. Writing $x \cdot x_i = \sum_{j=1}^m a_{ij} x_j$, there is the matrix equation
	\[ (X \cdot 1_{m \times m} - A) \begin{pmatrix} x_1 \\ \vdots \\ x_m \end{pmatrix} = 0, \quad A = (a_{ij})_{1 \leq i,j \leq m} \in \text{Mat}_{m \times m}(R) \]
	over $R[X]$. Now multiply both sides by the cofactor matrix $(X \cdot 1_{m \times m} - A)^\vee$, we get $P(X) x_i = 0$ for all $i$, where $P \in R[X]$ is the characteristic polynomial of $A$, i.e. $P(x)M = \{0\}$. Since $M$ is faithful as an $R[x]$-module, we get $P(x)=0$.
\end{proof}

\begin{corollary}
	The integral elements in an $R$-subalgebra $A$ form a subalgebra. In particular, $A$ is integral over $R$ if and only if it has a set of integral generators.
\end{corollary}
\begin{proof}
	Let $a, b \in A$ be integral elements. One readily checks that
	\begin{itemize}
		\item $R[a,b]$ is finitely generated as an $R$-module (say by certain monomials $a^i b^j$);
		\item $R[a,b]$ is faithful (as an $R[a,b]$-module) because it contains $1$.
	\end{itemize}
	Thus $R[a,b]$ witnesses the integrality of $a+b$ and $ab$, since they both stabilize $R[a,b]$.
\end{proof}

\begin{proposition}\label{prop:integrality-tower}
	Consider ring homomorphisms $R \to A \to B$ such that $A$ is integral over $R$. If $y \in B$ is integral over $A$, then it is integral over $R$. 
\end{proposition}
\begin{proof}
	Assume $y^n + a_{n-1} y^{n-1} + \cdots + a_0 = 0$ with $a_0, \ldots, a_{n-1} \in A$ integral over $R$. The $R[a_0, \ldots, a_{n-1}]$-module $R[a_0, \ldots, a_{n-1}][y]$ is also finitely generated over $R$, faithful and preserved by $y$, hence it witnesses the integrality of $y$ over $R$.
\end{proof}

This subalgebra of integral elements in $A$ is called the \emph{integral closure}\index{integral closure} of $R$ in $A$. If the integral closure equals the image of $R$ in $A$, we say $R$ is \emph{integrally closed} in $A$. The integral closure is automatically integrally closed by virtue of Proposition \ref{prop:integrality-tower}.

\begin{definition}\index{normal}
	Let $R$ be an integral domain and denote by $K$ its field of fractions. The integral closure of $R$ in $K$ is called the \emph{normalization} of $R$. The domain $R$ is said to be \emph{normal} if $R$ is integrally closed in $K$.
\end{definition}

The first examples of normal domains come from unique factorization domains (UFD) that you have seen in undergraduate algebra, including $\Z$, $\Q[X,Y]$, etc.

\begin{proposition}
	Unique factorization domains are normal.
\end{proposition}
\begin{proof}
	Given $x = r/s \in K$ with coprime $r,s \in R$. If there is an integral dependence relation $x^n + a_{n-1} x^{n-1} + \cdots + a_0 = 0$, we will have $r^n + a_{n-1} r^{n-1}s + \cdots + a_0 s^n = 0$, hence $s \mid r^n$. As $r$ is coprime to $s$, we see $s \in R^\times$ and $x \in R$.
\end{proof}

Let us show that taking integral closure commutes with localizations. Geometrically, this means that taking integral closure is a local operation on $\Spec(R)$.

\begin{lemma}
	Let $A$ be an $R$-algebra, $S$ be a multiplicative subset of $R$. Denote by $\tilde{R}$ the integral closure of $R$ in $A$. Then the integral closure of $R[S^{-1}]$ in $A[S^{-1}]$ equals $\tilde{R}[S^{-1}]$.
\end{lemma}
\begin{proof}
	Suppose that $x \in A$ satisfies $x^n + \sum_{i=0}^{n-1} b_i x^i = 0$ with $b_0, \ldots, b_{n-1} \in R$. For all $s \in S$ we deduce $\left(\frac{x}{s}\right)^n + \sum_{i=0}^{n-1} \frac{b_i}{s^{n-i}} \cdot \left( \frac{x}{s} \right)^i = 0$ in $A[S^{-1}]$. Therefore $\tilde{R}[S^{-1}]$ is in the integral closure of $R[S^{-1}]$ in $A[S^{-1}]$.

	Conversely, suppose that $x/s \in A[S^{-1}]$ satisfies
	\[ \left(\frac{x}{s}\right)^n + \sum_{i=0}^{n-1} \frac{a_i}{s_i} \left( \frac{x}{s} \right)^i = 0, \quad a_i \in A, \; s_i \in S. \]
	Cleaning denominators, we see that $x s_1 \cdots s_{n-1}$ is integral over $R$, hence $x = \frac{xs_1 \cdots s_{n-1}}{s_1 \cdots s_n} \in \tilde{R}[S^{-1}]$.
\end{proof}

In particular, localizations of a normal domain are still normal. We have the following converse.
\begin{exercise}
	Let $R$ be a domain. If for every maximal ideal $\mathfrak{m}$ of $R$ we have $R_{\mathfrak{m}}$ is normal, then so is $R$ itself. Hint: recall that $R = \bigcap_{\mathfrak{m}} R_{\mathfrak{m}}$ inside the fraction field $K$.
\end{exercise}

\begin{exercise}
	Let $R := \CC[X,Y]/(Y^2-X^3)$. Show that
	\begin{compactenum}[(i)]
		\item $R$ is a domain, or equivalently, $Y^2 - X^3$ is an irreducible polynomial;
		\item the element $x := \bar{Y}/\bar{X} \in \text{Frac}(R)$ does not lie in $R$, where $\bar{X},\bar{Y}$ denote the images of $X,Y \in \CC[X,Y]$;
		\item show that $x^3 \in R$, therefore $R$ is not a normal ring.
	\end{compactenum}
\end{exercise}

\begin{remark}
	The rationale of the previous Exercise comes from singularity. Consider the \emph{cuspidal curve} $C := \{ (x,y) \in \CC^2: y^2=x^3\}$. It has an isolated singularity at $(0,0)$ since $\nabla (y^2-x^3) = (0,0)$ at the origin. On the other hand, it admits a (non-injective) parametrization from $\CC$ by
	\[ t \mapsto (x=t^2, y=t^3). \]
	Following Milnor \cite{Mil68}, a nice way to understand the ``cusp'' at $(0,0)$ is to cut $C$ by a $3$-sphere $S := \{(x,y) \in \CC^2: |x|^2 + |y|^2 = \epsilon \}$ enclosing the origin, with $0 < \epsilon \ll 1$. Writing the parametrization above as $t=re^{i\theta}$ in polar coordinates, we get the equation $r^4 + r^6 = \epsilon$ which has a unique positive root $\rho$. Hence $S \cap C$ is described by the closed curve $\theta \mapsto (\rho^2 e^{2i\theta}, \rho^3 e^{3i\theta})$ in $S \simeq \mathbb{S}^3$. We call $S \cap C$ the \emph{link of singularity} at $(0,0)$; in this case it is equivalent to the $(2,3)$-torus knot, i.e. the \emph{trefoil} shown below.
	
	\begin{center}\vspace{1.5em}
		% Draw　the trefoil knot using the knots library in TikZ
		\begin{tikzpicture}
			\begin{knot}[
				consider self intersections,
				flip crossing = 2,
				clip width = 7]
			\strand[ultra thick, black]
				(90:2) to[out=180, in=-120, looseness=2]
				(-30:2) to[out=60, in=120, looseness=2]
				(210:2) to[out=-60, in=0, looseness=2] (90:2);
			\end{knot}
		\end{tikzpicture}
	\end{center}

	If we started from a non-singular curve in $\CC^2$, the result would then be an unknotted $\mathbb{S}^1$ inside $\mathbb{S}^3$. In this sense the link provides a measure for the singularity.
\end{remark}


Our study of normality has to be paused here. We refer to \cite[\S\S 8--9]{Mum99} for a beautiful discussion on the algebro-geometric content of normality, as well as important consequences such as Zariski's Main Theorem. Roughly speaking, normality means there is only one branch through each point of the corresponding variety.

\section{Nullstellensatz}
Our aim is to present a generalization of the celebrated \emph{Nullstellensatz}, which is one of the cornerstones of algebraic geometry. We shall also write the nilpotent radical of a ring $R$ as
\[ \text{nil}(R) := \sqrt{0_R}. \]
For an ideal $\mathfrak{a} \subset R$, we write $\mathfrak{a}[X]$ for the ideal of $R[X]$ formed by polynomials with all coefficients lying in $\mathfrak{a}$.

\begin{definition}\label{def:Jacobson-ring}\index{Jacobson ring}
	A ring $R$ is called a \emph{Jacobson ring} if every prime ideal $\mathfrak{p}$ satisfies
	\begin{gather}\label{eqn:Hilbert}
		\mathfrak{p} = \bigcap_{\mathfrak{m}: \text{maximal ideal } \supset \mathfrak{p}} \mathfrak{m}.
	\end{gather}
	Equivalently, we require that the Jacobson radical $\text{rad}(R/\mathfrak{p}) = \text{nil}(R/\mathfrak{p}) = \{0\}$ for all $\mathfrak{p}$. Note that $\supset$ always holds.
\end{definition}
Observations:
\begin{compactitem}
	\item Quotients of Jacobson rings are still Jacobson.
	\item Fields are trivially Jacobson.
\end{compactitem}

\begin{exercise}
	Prove that every principal ideal domain (a domain in which every ideal is generated by one element) with infinitely many maximal ideals is Jacobson.
\end{exercise}


\begin{theorem}[E.\ Snapper]\label{prop:Snapper}
	For any $R$, the polynomial algebra $R[X]$ satisfies $\mathrm{rad}(R[X]) = \mathrm{nil}(R[X])$.
\end{theorem}
\begin{proof}
	To show that $\text{nil}(R[X]) \supset \text{rad}(R[X])$, let $f(X) = \sum_i a_i X^i \in \text{rad}(R[X])$, then $1+Xf(X) = 1 + \sum_i a_i X^{i+1} \in R[X]^\times$. By looking at the reduction modulo $\mathfrak{p}$ of $f(X)$ for every prime ideal $\mathfrak{p}$ of $R$, we see that $a_i \in \bigcap \mathfrak{p} = \text{nil}(R)$ for all $i$. Hence $f(X) \in \text{nil}(R)[X] \subset \text{nil}(R[X])$.
\end{proof}

\begin{lemma}
	Let $R \subset A$ be integral domains such that $A$ is a finitely generated $R$-algebra. If $\mathrm{rad}(R)=\{0\}$, then $\mathrm{rad}(A)=\{0\}$.
\end{lemma}
\begin{proof}
	We may assume that $A$ is generated by a single element $a \in A$ over $R$. If $a$ is transcendental over $K := \text{Frac}(R)$, Theorem \ref{prop:Snapper} above can be applied as $\mathrm{nil}(R[X]) = \{0\}$. Let us assume that $a$ satisfies $f(a)=0$ for some $f(X) = \sum_{i=0}^n r_i X^i \in R[X]$ with $r_n \neq 0$. Let $b \in \text{rad}(A)$ and suppose $b \neq 0$. Hereafter we embed everything into the $K$-algebra $\text{Frac}(A)$. Since $a$ is algebraic over $K$, so is every element from $R[a]$ or even $K[a] \subset \text{Frac}(A)$. Hence $b$ is integral over $K$ as well. By cleaning denominators, we arrive at $g(b)=0$ for some $g(X) = \sum_{i=0}^m s_i X^i \in R[X]$ with the smallest possible degree $m$. Since $A$ is a domain, we have $s_0 \neq 0$.

	Using $\text{rad}(R) =\{0\}$, there exists a maximal ideal $\mathfrak{m}$ of $R$ such that $r_n s_0 \not\in \mathfrak{m}$. Taking localization at $\mathfrak{m}$, we get the subring $A' := A \otimes_R R_{\mathfrak{m}} \subset \text{Frac}(A)$ containing $R_{\mathfrak{m}}$, and $A'$ is also a finitely generated $R_{\mathfrak{m}}$-module since we inverted $r_n$. Nakayama's Lemma for $R_{\mathfrak{m}}$-modules implies $\mathfrak{m} A' \subsetneq A'$, thus $\mathfrak{m} A \subsetneq A$. Now choose a maximal ideal $\mathfrak{m}_A$ of $A$ over $\mathfrak{m}$. We must have $\mathfrak{m}_A \cap R = \mathfrak{m}$, which entails $s_0 \not\in \mathfrak{m}_A$. This is a contradiction since $s_0 = -\sum_{i=1}^m s_i b^i \in \text{rad}(A)$.
\end{proof}

\begin{theorem}[Nullstellensatz]\label{prop:Nullstellensatz-gen}\index{Nullstellensatz}
	Let $A$ be a finitely generated $R$-algebra. Assume that $R$ is a Jacobson ring, then the following statements hold.
	\begin{enumerate}[(i)]
		\item $A$ is a Jacobson ring.
		\item Let $\mathfrak{n} \in \Spec(A)$ be maximal, then its image $\mathfrak{m} \in \Spec(R)$ is maximal as well, and $A/\mathfrak{n}$ is a finite extension of the field $R/\mathfrak{m}$.
	\end{enumerate}
\end{theorem}
\begin{proof}
	We start with (i). One may assume $R \subset A$ from the outset. Condition \eqref{eqn:Hilbert} for $A$ amounts to $\text{rad}(A/\mathfrak{p})=0$ for every $\mathfrak{p} \in \Spec(A)$. Apply the previous Lemma to the integral domains $R/R \cap \mathfrak{p} \subset A/\mathfrak{p}$ to prove (i).
	
	Now turn to (ii). Using (i) and induction, we may assume that $A=R[a]$ for some $a \in A$. By considering the homomorphism $R/\mathfrak{m} \hookrightarrow A/\mathfrak{n}$ between Jacobson rings, we may further reduce to the case $\mathfrak{n}=\{0\}$ and $\mathfrak{m}=\{0\}$, so that $R$ is a domain embedded in the field $A$. In particular $a$ cannot be transcendental (as $R[X]$ is not a field) and must satisfy $\sum_{i=0}^n c_i a^i = 0$ for some $c_0, \ldots, c_n \in R$ with $c_n \neq 0$. Let $\mathfrak{k}$ be any maximal ideal of $R$ not containing $c_n$, which exists since $\text{rad}(R) = \{0\}$.
	
	As in the proof of the previous Lemma, $a$ becomes integral over $R_{\mathfrak{k}}$ and Nakayama's Lemma for $R_{\mathfrak{k}}$-modules entails $\mathfrak{k}A \neq A$, hence $\mathfrak{k}=0$ because $A$ is a field. This implies that $R$ is a field and $A$ is a finite extension of $R$.
\end{proof}

\begin{corollary}
	Let $\Bbbk$ be an algebraically closed field, and $A := \Bbbk[X_1, \ldots, X_n]$. The maximal ideals of $A$ are in bijection with $\Bbbk^n$ by attaching to each $x := (x_1, \ldots, x_n) \in \Bbbk^n$ the ideal
	\[ \mathfrak{m}_x = \{f \in A : f(x)=0 \} = (X_1 - x_1, \ldots, X_n - x_n). \]
\end{corollary}
\begin{proof}
	Since $A/\mathfrak{m}_x \rightiso \Bbbk$ by evaluation at $x$, we see $\mathfrak{m}_x$ is indeed maximal. It is routine to show that $x = y \iff \mathfrak{m}_x = \mathfrak{m}_y$. It remains to show that every maximal ideal $\mathfrak{n}$ contains some $\mathfrak{m}_x$. Indeed, Theorem \ref{prop:Nullstellensatz-gen} implies the field $A/\mathfrak{n}$ is algebraic over $\Bbbk$, hence $A/\mathfrak{n} \simeq \Bbbk$ as $\Bbbk$-algebras. Let $x_i$ be the image of $X_i$ under $A \twoheadrightarrow A/\mathfrak{n} \rightiso \Bbbk$ and set $x := (x_1, \ldots, x_n)$, then $\mathfrak{n} \supset \mathfrak{m}_x$ as required.
\end{proof}

\begin{corollary}
	Keep the notations above and set
	\begin{align*}
		Z(\mathfrak{a}) & := \{x \in \Bbbk^n: \forall f \in \mathfrak{a}, \; f(x)=0 \}, \\
		I(\mathcal{X}) & := \{f \in A: \forall x \in X, \; f(x)=0 \}
	\end{align*}
	for ideals $\mathfrak{a} \subset A$ and subsets $\mathcal{X} \subset \Bbbk^n$, then we have $IZ(\mathfrak{a}) = \sqrt{\mathfrak{a}}$ for all $\mathfrak{a}$.		
\end{corollary}
If we identify $\Bbbk^n$ with $\MaxSpec(A)$ by the previous Corollary, then $Z(\mathfrak{a})$ is just the intersection of $V(\mathfrak{a}) \subset \Spec(A)$ and $\MaxSpec(A)$. Details are left to the readers.
\begin{proof}
	If $f \in A$ and $f^n \in \mathfrak{a}$ for some $n$, the vanishing of $f^n$ on $Z(\mathfrak{a})$ will entail that of $f$, hence the inclusion $\supset$ holds. Assume conversely that $f \in A$ vanishes on $Z(\mathfrak{a})$. This means: for every maximal ideal $\mathfrak{m}_x$ we have
	\[ \mathfrak{m}_x \supset \mathfrak{a} \iff x \in Z(\mathfrak{a}) \implies f(x)=0 \iff f \in \mathfrak{m}_x. \]
	Hence
	\[ f \in \bigcap_{\mathfrak{m}_x \supset \mathfrak{a}} \mathfrak{m}_x = \sqrt{\mathfrak{a}}, \]
	the last equality being based on Definition \ref{def:Jacobson-ring} since $A/\mathfrak{a}$ is a Jacobson ring. This concludes the $\subset$.
\end{proof}

\begin{remark}
	How about $Z I(\mathcal{X})$? Unwinding definitions, it is seen to equal the set of points that ``satisfy the algebraic equations that $\mathcal{X}$ satisfies.'' The Zariski topology on $\Bbbk^n$ is defined by stipulating the subsets $\{ x \in \Bbbk^n: f(x)=0 \}$ to be closed, for all $f \in A$, so we obtain $ZI(\mathcal{X}) = \bar{\mathcal{X}}$, the Zariski-closure of $\mathcal{X}$. The reader is invited to verify that by identifying $\Bbbk^n$ with $\MaxSpec(A)$, the foregoing topology is induced from the Zariski topology on the prime spectrum $\Spec(A)$.
\end{remark}

An (algebraic, closed) subvariety of $\Bbbk^n$ is the vanishing locus $f_1 = \cdots = f_m = 0$ for some $f_1, \ldots, f_m \in \Bbbk[X_1, \ldots, X_n]$; it is determined by the ideal $\mathfrak{a} = (f_1, \ldots, f_m)$, in fact it depends only on $\sqrt{\mathfrak{a}}$. An ideal $\mathfrak{a}$ is called \emph{radical} if $\sqrt{\mathfrak{a}}=\mathfrak{a}$. To recap, we obtain a dictionary:
\begin{center}\begin{tabular}{c|c}
	Subvariety $\mathcal{X}$ in $\Bbbk^n$ & Radical ideal $\mathfrak{a}$ in $\Bbbk[X_1, \ldots, X_n]$ \\
	Points of $\mathcal{X}$ & $\MaxSpec(A)$, \;$A = A_{\mathcal{X}} := \Bbbk[X_1, \ldots, X_n]/\mathfrak{a}$ \\
	Union of two varieties & product or intersection of two ideals \\
	Intersection of varieties & sum of ideals \\
	Polynomial map $\mathcal{X} \to \mathcal{Y}$ & $\Bbbk$-homomorphism $A_{\mathcal{Y}} \to A_{\mathcal{X}}$ \\
	\vdots & \vdots
\end{tabular}\end{center}

If one allows arbitrary rings $A$ instead of just $\Bbbk[X_1, \ldots, X_n]/\mathfrak{a}$, and consider $\Spec(A)$ instead of $\MaxSpec(A)$ (the latter is well-behaved only for Jacobson rings), the result is the category of \emph{affine schemes}. A proper treatment of these ideas should be left to the Algebraic Geometry course, if it exists......

\section{Flatness: the first glance}
To begin with, we consider a ring $A$ and a module $N$. It has been observed that the additive functor $N \dotimes{A} -: A\dcate{Mod} \to A\dcate{Mod}$ is \emph{right exact}, namely it preserves the exactness of sequences like
\[ \bullet \to \bullet \to \bullet \to 0. \]
If we consider exactness of sequences like $0 \to \bullet \to \bullet \to \bullet$, the corresponding notion is \emph{left exactness}. The same applies to any additive functor $F$ instead of $N \dotimes{A} -$. Being both left and right exact is equivalent to that $F$ preserves all exact sequences; in this case we say $F$ is an \emph{exact functor}.

\begin{definition}\index{flat}\index{faithfully flat}
	We say $N$ is a \emph{flat} $A$-module if $N \dotimes{A} -$ is exact. We say $N$ is \emph{faithfully flat} if for every sequence $M_\bullet = [\cdots \to M_i \to M_{i-1} \to \cdots]$ of $R$-modules, we have $M_\bullet \dotimes{R} N$ is exact if and only if $M_\bullet$ is.
\end{definition}

\begin{remark}
	In view of the right-exactness of $\otimes$, to assure flatness of $N$ it suffices that $N \dotimes{A} -$ preserves kernels.
\end{remark}

Now we consider a ring homomorphism $A \to B$, which makes $B$ into an $A$-algebra. Tensor product now gives an additive functor, often called the \emph{base change}:
\[ B \dotimes{A} -: A\dcate{Mod} \to B\dcate{Mod}. \]
Thus we can also talk about flatness and faithful flatness of $B$ over $A$. Since $B$ is naturally an $A$-module, this notion is compatible with the previous one.
\begin{example}\label{eg:localization-flatness}
	Let $S$ be a multiplicative subset of $A$, then $A[S^{-1}]$ is flat over $A$. It is not faithfully flat in general, however; see Theorem \ref{prop:faithfully-flat-criterion}.
\end{example}

\begin{example}
	A routine fact is that for any family $\left( M^{(i)}_\bullet \right)_{i \in I}$ of complexes of $A$-modules, we have
	\[ \forall i \in I, \; M^{(i)}_\bullet \text{ is exact} \iff \bigoplus_{i \in I} M^{(i)}_\bullet \text{ is exact}. \]
	Recall that $\otimes$ preserves direct sums. It follows that a direct sum of modules is flat if and only if each summand is flat. From this we deduce the flatness of free modules since $A \dotimes{A} M \simeq M$ functorially for each $M$. Furthermore, projective modules are flat as they are direct summands of free modules.
\end{example}

\begin{exercise}
	Show that $\Z/n\Z$ is not flat over $\Z$ for $n > 1$.
\end{exercise}

We list some basic properties below.
\begin{description}
	\item[Tensor products] Let $M,N$ be flat (resp. faithfully flat) $R$-modules, then so is $M \dotimes{R} N$. This follows the associativity constraint of tensor products: $(- \otimes M) \otimes N \simeq - \otimes (M \otimes N)$.
	\item[Transitivity] Given ring homomorphisms $A \to B \to C$, if $B$ is flat (resp. faithfully flat) over $A$ and $C$ is flat (resp. faithfully flat) over $B$, then $C$ is also flat (resp. faithfully flat) over $A$. This follows from the transitivity of base change, namely there is a isomorphism of functors $A\dcate{Mod} \to C\dcate{Mod}$.
	\[ (- \dotimes{A} B) \dotimes{B} C \rightiso - \dotimes{A} C. \]
	\item[Base change] Suppose $N$ is a flat (resp. faithfully flat) $A$-module and $B$ is any $A$-algebra, then $N \dotimes{A} B$ is a flat (resp. faithfully flat) $B$-module. Again, any $B$-module $M$ can be viewed as an $A$-module, and there is a functorial isomorphism
	\[ (N \dotimes{A} B) \dotimes{B} M \rightiso N \dotimes{A} M. \]
\end{description}

\begin{remark}\label{rem:exactness-local}
	A sequence $[ \cdots \to M_i \xrightarrow{d_i} M_{i-1} \to \cdots]$ of $R$-modules is a complex (resp. exact) if and only if so is its localization at $\mathfrak{m}$, for every maximal ideal $\mathfrak{m}$. Indeed:
	\begin{compactitem}
		\item $(M_\bullet, d_\bullet)$ is a complex if and only if $\Image(d_{i-1}d_i)=0$ for all $i$. Since localization is an exact functor, it preserves images and we know a module $N$ is zero if and only if $N_{\mathfrak{m}}=0$ for all $\mathfrak{m}$.
		\item a complex $(M_\bullet, d_\bullet)$ is exact if and only if $\Hm_i(M_\bullet)=0$ for all $i$. The same reasoning applies since localization preserves $H_i$.
	\end{compactitem}
\end{remark}

\begin{proposition}
	The following are equivalent for an $R$-module $N$.
	\begin{inparaenum}[(i)]
		\item $N$ is flat over $R$,
		\item $N_{\mathfrak{p}}$ is flat over $R_{\mathfrak{p}}$ for all prime ideal $\mathfrak{p}$,
		\item $N_{\mathfrak{m}}$ is flat over $R_{\mathfrak{m}}$ for all maximal ideal $\mathfrak{m}$.
	\end{inparaenum}
\end{proposition}
\begin{proof}
	Direct consequence of the exactness of localization and Remark \ref{rem:exactness-local}.
\end{proof}

\begin{lemma}\label{prop:flat-ring-localizations}
	Let $\varphi: R \to R'$ be a ring homomorphism, $\mathfrak{p}' \in \Spec(R')$ maps to $\mathfrak{p} \in \Spec(R)$ under $\varphi^\sharp$. If $\varphi$ is flat, so is the induced homomorphism $R_{\mathfrak{p}} \to R'_{\mathfrak{p}'}$.
\end{lemma}
\begin{proof}
	Set $S = R \smallsetminus \mathfrak{p}$ so that $\varphi(S) \subset R' \smallsetminus \mathfrak{p}'$. Factorize $R_{\mathfrak{p}} \to R_{\mathfrak{p}'}$ as
	\[ R_{\mathfrak{p}} \to \underbracket{R'[\varphi(S)^{-1}]}_{\text{as a ring}} \to R'_{\mathfrak{p}'}. \]
	The first arrow is also the base-change to $R_{\mathfrak{p}}$ of $\varphi$ (as a homomorphism of $R$-modules), whereas the second one is a localization of $R'$. Their composite is therefore flat.
\end{proof}

\begin{proposition}\label{prop:flatness-localized}
	Let $\varphi: R \to R'$ be a ring homomorphism. The following are equivalent:
	\begin{enumerate}[(i)]
		\item $R'$ is flat over $R$,
		\item $R'_{\mathfrak{p}'}$ is flat over $R_{\mathfrak{p}}$ for all $\mathfrak{p}' \in \Spec(R')$ with $\mathfrak{p} = \varphi^\sharp(\mathfrak{p}')$;
		\item \emph{Idem}, but for $\mathfrak{p}' \in \MaxSpec(R')$.
	\end{enumerate}
\end{proposition}
\begin{proof}
	(i) $\implies$ (ii): Set $S := R \smallsetminus \mathfrak{p}$. Base change implies $R'[S^{-1}]$ is flat over $R[S^{-1}] = R_{\mathfrak{p}}$. Since $R'_{\mathfrak{p}'}$ is a localization of $R[S^{-1}]$ (exercise), we conclude by transitivity.
	
	(ii) $\implies$ (iii): Trivial.
	
	(iii) $\implies$ (i): By Remark \ref{rem:exactness-local} applied to complexes of $R'$-modules, it suffices to show the exactness of the functor $- \dotimes{R} R'_{\mathfrak{p}'}$ for all $\mathfrak{p}' \in \MaxSpec(R')$. In view of Lemma \ref{prop:flat-ring-localizations}, the factorization of $R \to R'_{\mathfrak{p}'}$ into $R \to R_{\mathfrak{p}} \to R'_{\mathfrak{p}'}$ and the flatness of $R \to R_{\mathfrak{p}}$ show that $R'_{\mathfrak{p}'}$ is indeed flat over $R$.
\end{proof}

\begin{lemma}[Equational criterion of flatness]\label{prop:equational-flatness}
	An $R$-module $N$ is flat if and only if for all $r \geq 1$, $a_1, \ldots, a_r \in R$, $x_1, \ldots, x_r \in N$ verifying $\sum_{i=1}^r a_i x_i = 0$, there exist $s \in \Z_{\geq 1}$, an $R$-valued matrix $B = (b_{ij})_{\substack{1 \leq i \leq r \\ 1 \leq j \leq s }}$ and $y_1, \ldots, y_s \in N$ such that
	\[ \begin{pmatrix} x_1 \\ \vdots \\ x_r \end{pmatrix} = B \begin{pmatrix} y_1 \\ \vdots \\ y_s \end{pmatrix}, \quad \begin{pmatrix} a_1 & \cdots & a_r \end{pmatrix} B = 0. \]
\end{lemma}
\begin{proof}
	Suppose $M$ is flat and consider the exact sequence $0 \to \Ker(f) \to R^{\oplus r} \xrightarrow{f} R$ where $f(t_1, \ldots, t_r) = \sum_i a_i t_i$. We obtain an exact
	\[ 0 \to \Ker(f) \dotimes{A} M \to M^{\oplus r} \xrightarrow{(x_i)_i \mapsto \sum_i a_i x_i} M. \]
	Thus if $(x_1, \ldots, x_r) \mapsto 0$ by the arrow above, we can express it as $\sum_{j=1}^s (b_{1j}, \ldots, b_{rj}) \otimes y_j \in \Ker(f) \dotimes{A} M$ as required.
	
	To show the converse, we invoke the fact that flatness is equivalent to the injectivity of $\mathfrak{a} \otimes N \to \mathfrak{a} N$ for all finitely generated ideal $\mathfrak{a}$. See Proposition \ref{prop:flat-module}.
\end{proof}

It will be useful to rephrase the condition in Lemma \ref{prop:equational-flatness} as follows: for all
\begin{compactitem}
	\item homomorphism $x: R^{\oplus r} \to M$, where $r \in \Z_{\geq 1}$, and
	\item $K \subset \Ker(x)$: submodule generated by one element,
\end{compactitem}
there exist some $s \in \Z_{\geq 1}$ and a commutative diagram
\[\begin{tikzcd}[column sep=small]
	R^{\oplus r} \arrow[rd, "x"'] \arrow[rr, "B"] & & R^{\oplus s} \arrow[ld, "y"] \\
	& M &
\end{tikzcd} \quad \text{s.t. } K \subset \Ker(B). \]
Indeed, $x$ (resp. $y$) corresponds to $(x_1, \ldots, x_r)$ via $x: (t_1, \ldots, t_r) \mapsto \sum_i t_i x_i$ (resp. $y: (u_1, \ldots, u_s) \mapsto \sum_j u_j, y_j$), and $K \subset \Ker(x)$ corresponds to $R \cdot (a_1, \ldots, a_r)$. The homomorphism $B$ corresponds to the matrix $(b_{ij})_{i,j}$.

\begin{remark}\label{rem:equational-flatness-ext}
	For flat $N$, the equational criterion so rephrased is applicable to any finitely generated $K \subset \Ker(x)$. Indeed, one may iterate the construction for $R^{\oplus s} \xrightarrow{y} M$, etc. to make every generator of $K$ mapped to $0$.
\end{remark}

\section{Structure of flat modules}
Recall from homological algebra that the right exact functor $N \dotimes{A} -: R\dcate{Mod} \to R\dcate{Mod}$ has $(\Tor_i^R(N, -))_{i \geq 0}$ as its left derived functors.
\begin{proposition}\label{prop:flat-module}
	The following are equivalent for an $R$-module $N$:
	\begin{enumerate}[(i)]
		\item $N$ is flat,
		\item $\Tor_i^R(N,-)=0$ for all $i > 0$,
		\item $\Tor_1^R(N,-)=0$,
		\item $\Tor_1^R(N, R/\mathfrak{a})=0$ for all finitely generated ideal $\mathfrak{a}$, or equivalently $\mathfrak{a} \dotimes{R} N \to N$ is injective.
	\end{enumerate}
\end{proposition}
\begin{proof}
	First, the equivalence mentioned in (iv) is a consequence of the exact sequence
	\[ \underbracket{\Tor_1^R(N, R)}_{=0} \to \Tor_1^R(N, R/\mathfrak{a}) \to N \dotimes{R} \mathfrak{a} \to N \to N \dotimes{R} (R/\mathfrak{a}) \to 0 \]
	deduced from $0 \to \mathfrak{a} \to R \to R/\mathfrak{a} \to 0$.

	Clearly (i) $\implies$ (ii) $\implies$ (iii) $\implies$ (iv). To show (iii) $\implies$ (i), note that if $0 \to M' \to M \to M'' \to 0$ is exact, then $\Tor_1^R(N,M'') \to N \otimes M' \to N \otimes M \to N \otimes M'' \to 0$ is exact.
	
	We show (iv) $\implies$ (i), (ii) or (iii) as follows: $\Tor_1^R(N,M)=0$ can be tested for finitely generated $M$ only, since $\Tor^R_i(N,-)$ preserves filtered inductive limits such as
	\[ M = \varinjlim \left\{ \text{f.g. submodules} \right\}. \]
	We do induction on the minimal number $n$ of generators of $M$. If $M = Rx_1 + \cdots + Rx_n$, put $M' := \sum_{i < n} Rx_i$ so that we have a short exact sequence $0 \to M' \to M \to M'' \to 0$ where $M''$ is generated by the image of $x_n$, hence isomorphic to some $R/\mathfrak{a}$. Since $\Tor_1^R(N,M') \to \Tor_1^R(N, M) \to \Tor_1^R(N, M'')$ is exact, we are reduced to the $n=1$ case, i.e. $M = R/\mathfrak{a}$. It boils down to assure $\mathfrak{a} \otimes N \hookrightarrow N$. Again, using the exactness of filtered $\varinjlim$ and the fact that $\otimes$ respects $\varinjlim$, it suffices to test this on finitely generated $\mathfrak{a}$.
	
	For a down-to-earth approach, see \cite[\S 6.3]{Eis95}.
\end{proof}

\begin{corollary}
	If $r \in R$ is not a zero divisor, then $r$ is not a zero divisor for any flat $R$-module $N$.
\end{corollary}
\begin{proof}
	Take $\mathfrak{a} :=Rr$, which is $\simeq R$, and contemplate on $N \simeq \mathfrak{a} \dotimes{R} N \hookrightarrow N$.
\end{proof}

\begin{exercise}
	Suppose $R$ is a principal ideal domain. Show that $N$ is flat if and only if $N$ has no zero divisors except $0$. Hint: the ideals take the form $\mathfrak{a} = (t)$, so the condition (iv) amounts to $tx=0 \iff x=0$.
\end{exercise}

\begin{exercise}
	For all field $\Bbbk$, show that
	\begin{compactenum}[(i)]
		\item $\Bbbk[X,Y]/(XY-X)$ is not flat over $\Bbbk[X]$,
		\item $\Bbbk\llbracket t \rrbracket[Y,Z]/(YZ-t)$ is flat over $\Bbbk\llbracket t\rrbracket$.
	\end{compactenum}
\end{exercise}

\begin{lemma}
	Suppose $A \to B$ is flat. Write $M_B := B \dotimes{A} M$ for any $A$-module $B$. Then there are natural isomorphisms $\Tor_i^B(M_B, N_B) \simeq B \dotimes{A} \Tor_i^A(M,N)$ for all $i$.
\end{lemma}
\begin{proof}
	Take a projective resolution $0 \leftarrow M \leftarrow P_\bullet$ of $A$-modules. Since $B$ is flat over $A$, its base-change $0 \leftarrow M_B \leftarrow P_{\bullet,B}$ to $B$ is still a projective resolution; we are using the fact that base-change preserves projectivity. Hence $\Hm_i(P_{\bullet,B} \dotimes{B} N_B)$ computes $\Tor_i^B(M_B, N_B)$. On the other hand, by flatness the homology groups are equal to $\Hm_i(P_\bullet \dotimes{A} N) \dotimes{A} B$, that is, $\Tor_i^A(M,N) \dotimes{A} B$. We leave it to the reader to convince him- or herself that the isomorphism so constructed is natural.
	
	Another way is to use to associativity and commutativity of tensor products on the derived level, namely the flatness of $A \to B$ implies
	\[ M_B \otimesL_B N_B \simeq (M \otimesL_A B) \otimesL_B (N \otimes_A B) \simeq (M \otimesL_A N) \otimesL_A B \]
	in the derived categories, and it remains to take $\Hm_i$.
\end{proof}
In particular, let $S \subset R$ be a multiplicative subset. By Example \ref{eg:localization-flatness} we infer
\[ \Tor_i^{R[S^{-1}]}\left( M[S^{-1}], N[S^{-1}] \right) \simeq \Tor_i^R(M,N)[S^{-1}]. \]

\begin{theorem}\label{prop:free-proj}
	Let $R$ be a local ring with maximal ideal $\mathfrak{m}$. Let $M$ be a finitely generated $R$-module. The following are equivalent:
	\begin{compactitem}
		\item $M$ is free,
		\item $M$ is projective.
	\end{compactitem}
	If we assume moreover that $M$ is finitely presented, both conditions are equivalent to the flatness of $M$.
\end{theorem}
\begin{proof}
	Free modules are known to be projective. Now let $M$ be finitely generated projective, and take a basis $\bar{x}_1, \ldots \bar{x}_n$ of the $R/\mathfrak{m}$-vector space $M/\mathfrak{m}M$, together with liftings $M \ni x_i \mapsto \bar{x}_i$. Nakayama's Lemma then implies the surjectivity of
	\begin{align*}
		\Phi: R^{\oplus n} & \longrightarrow M \\
		(a_1, \ldots, a_n) & \longmapsto a_1 x_1 + \cdots + a_n x_n.
	\end{align*}
	As $M$ is projective, $\Phi$ admits a section so that we may identify $M$ with a direct summand of $R^{\oplus n}$, namely $M \oplus N = R^{\oplus n}$ for some $N$. Taking $- \otimes_R R/\mathfrak{m}$ leads to
	\[ (R/\mathfrak{m})^{\oplus n} = M/\mathfrak{m}M \oplus N/\mathfrak{m}N \quad \text{as vector spaces over } R/\mathfrak{m}, \]
	and by comparing dimensions we see $N/\mathfrak{m}N = \{0\}$, which in turn gives $N = \{0\}$ by Nakayama's Lemma ($N$ is finitely generated since $R^{\oplus n} \twoheadrightarrow N$). Hence $M \simeq R^{\oplus n}$ is free.
	
	Now turn to the second assertion. Projective modules are flat since they are direct summands of free modules, and it remains to show that every flat $M$ with finite presentation $R^{\oplus q} \to R^{\oplus r} \xrightarrow{x} M \to 0$ is a direct summand of a free module. Let's plug $x: R^{\oplus r} \twoheadrightarrow M$ and $K := \Ker(x)$ into the equational criterion of flatness (Lemma \ref{prop:equational-flatness}), rephrased as in Remark \ref{rem:equational-flatness-ext}. Let $N$ be the image of $B: R^{\oplus r} \to R^{\oplus s}$. One readily sees that $y$ induces $N \rightiso M$. This furnishes a section $s: M \to R^{\oplus s}$ for $y$.
\end{proof}

We deduce the following result characterizing finitely presented projective modules: in geometric language, they correspond to \emph{vector bundles} over the \emph{affine scheme} $\Spec(R)$.
\begin{corollary}
	Let $M$ be a finitely presented $R$-module. Then $M$ is projective if and only $M_{\mathfrak{m}}$ is free for every maximal ideal $\mathfrak{m}$.
\end{corollary}
\begin{proof}
	In view of Theorem \ref{prop:free-proj}, it suffices to show $M$~is projective if and only if $M_{\mathfrak{m}}$ is for all maximal ideal $\mathfrak{m}$. One direction is easy: if $M$ is a direct summand of a free module, then so is $M_{\mathfrak{m}}$.

	Conversely, the assumption on finite presentation entails an isomorphism between additive functors $R\dcate{Mod} \to R_{\mathfrak{m}}\dcate{Mod}$
	\[ \Hom_R(M, -) \dotimes{R} R_{\mathfrak{m}} \simeq \Hom_{R_{\mathfrak{m}}}(M_{\mathfrak{m}}, (-)_{\mathfrak{m}}). \]
	Hence $M_{\mathfrak{m}}$ is projective for all $\mathfrak{m}$ implies $M$ is projective, by Remark \ref{rem:exactness-local} and the exactness of localizations.
\end{proof}

Note that for finitely presented $M$, the equivalence between projectivity and flatness holds for any ring $R$. The arguments are verbatim, and this can also be deduced from the local case.

We close this section by a stronger result, whose proof is referred to \cite[Theorem A6.6]{Eis95}.
\begin{theorem}[Govorov--Lazard]
	An $R$-module is flat if and only if it is a filtered $\varinjlim$ of free $R$-modules.
\end{theorem}

\section{Faithful flatness and surjectivity}
We begin by a contemplation on the definition of faithful flatness. Recall that $R\dcate{Mod}$ is the template of \emph{abelian categories}, in which one can talk about the zero object $0$, direct sums, kernels, cokernels, images and exactness.

We say a functor between categories is \emph{faithful} if it induces injections on $\Hom$-sets. A functor between additive categories is called \emph{additive} if it induces group homomorphisms between $\Hom$-sets. An additive functor between abelian categories is \emph{exact} if it preserves all exact sequences. Exact functors preserve kernels, cokernels and images.

\begin{lemma}\label{prop:faithful-functor} \index{faithfully flat}\index{faithful functor}
	Let $F: \mathcal{C} \to \mathcal{C}'$ be an additive functor between abelian categories. The following are equivalent.
	\begin{enumerate}[(i)]
		\item $F$ is exact and faithful;
		\item $F$ is exact and $(FM=0 \iff M=0)$ for every object $M$ of $\mathcal{C}$;
		\item a sequence $M' \to M \to M''$ is exact in $\mathcal{C}$ if and only if $FM' \to FM \to FM''$ is exact in $\mathcal{C}'$.
	\end{enumerate}
\end{lemma}
\begin{proof}
	(i) $\implies$ (ii): If $FM=0$ then $F(\identity_M)=\identity_{FM}=0$, and the faithfulness implies $\identity_M=0$ in $\End_{\mathcal{C}}(M)$; this is possible only when $M=0$.

	(ii) $\implies$ (i): Suppose $u: N \to M$ is mapped to $0$ under $F$. Then we have $F(\Image(u))=0$, thereby $\Image(u)=0$ and $u=0$.

	(i) $\implies$ (iii): Suppose $M' \xrightarrow{u} M \xrightarrow{v} M''$ induces an exact sequence $FM' \xrightarrow{Fu} FM \xrightarrow{Fv} FM''$. From $F(vu) = F(v)F(u) = 0$ we get $vu=0$. Thus it makes sense to define $C := \Ker(v)/\Image(u)$. One has an exact sequence
	\[ \Image(u) \to \Ker(v) \to C \to 0. \]
	Since $F$ is exact, we deduce $FC=0$, which implies $C=0$ by (i) $\implies$ (ii).

	(iii) $\implies$ (i): Suppose $u: N \to M$ is mapped to $0$ under $F$. Consider $v: M \to \Coker(u)$. Since $F$ preserves exact sequences and $Fv$ is an isomorphism, we see $v$ is also an isomorphism, therefore $u=0$.
\end{proof}

\begin{proposition}\label{prop:faithful-flatness-crit}
	The following are equivalent for an $R$-module $N$.
	\begin{compactenum}[(i)]
		\item $N$ is faithfully flat.
		\item The functor $- \dotimes{R} N$ is exact and faithful.
		\item $N$ is flat and for every maximal ideal $\mathfrak{m}$ of $R$, we have $N/\mathfrak{m}N \simeq N \dotimes{R} R/\mathfrak{m} \neq 0$.
	\end{compactenum}
\end{proposition}
\begin{proof}
	The equivalence (i) $\iff$ (ii) has just been established. An $R$-module $M$ is nonzero if and only if there exist exact sequences
	\[ 0 \to R/\mathfrak{a} \to M, \quad R/\mathfrak{a} \to R/\mathfrak{m} \to 0 \]
	where $\mathfrak{a}$ is a proper ideal and $\mathfrak{m}$ is a maximal over-ideal of $\mathfrak{a}$. Next, let's show (iii) $\implies$ (i) or (ii): there are exact sequences
	\[ 0 \to T \to M \dotimes{R} N, \quad T \to M \dotimes{R} (R/\mathfrak{m}) \to 0 \]
	where $T := (R/\mathfrak{a}) \dotimes{R} N$, therefore $M \dotimes{R} N \neq 0$ and we apply Lemma \ref{prop:faithful-functor}. Finally, (i) or (ii) $\implies$ (iii) is clear.
\end{proof}

\begin{corollary}
	Let $R \to R'$ be a local homomorphism\footnote{That is, the preimage of the maximal ideal $\mathfrak{m}_{R'}$ equals $\mathfrak{m}_R$.} between local rings and let $M$ be a finitely generated $R'$-module, $M \neq 0$. Then as an $R$-module, $M$ is faithfully flat if and only if it is flat.
\end{corollary}
\begin{proof}
	Let $\mathfrak{m}, \mathfrak{m}'$ be the maximal ideals of $R, R'$, respectively. Since $\mathfrak{m}$ is mapped into $\mathfrak{m}' = \text{rad}(R')$, the assertion follows from Proposition \ref{prop:faithful-flatness-crit} together with Nakayama's Lemma.
\end{proof}

This is often applied to the cases $R=R'$ or $M=R'$.

\begin{exercise}[Faithfully flat descent for flatness]
	Given a faithfully flat homomorphism $\varphi: R \to R'$. If $M$ is an $R$-module such that $M \dotimes{R} R'$ is a flat (resp. faithfully flat) $R'$-module, then so is $M$ over $R$.
\end{exercise}

\begin{proposition}\label{prop:faithfully-flat-surj}
	Suppose $\varphi: A \to B$ is a faithfully flat ring homomorphism and regard $B$ as an $A$-algebra.
	\begin{itemize}
		\item For any $A$-module $M$, the natural map $M \to M \dotimes{A} B$ is injective; in particular, $\varphi$ is seen to be injective by taking $M=A$.
		\item For any ideal $\mathfrak{a} \subsetneq A$ we have $\varphi^{-1}(\mathfrak{a}B)=\mathfrak{a}$.
		\item The map $\varphi^\sharp: \Spec(B) \to \Spec(A)$ is surjective.
	\end{itemize}
\end{proposition}
\begin{proof}
	Let $N$ be the kernel of $M \to M \dotimes{A} B$. The $B$-module homomorphism $N \dotimes{A} B \to M \dotimes{A} B$ is injective by flatness; it is zero on $N \otimes 1$, hence identically zero and we obtain $N = \{0\}$ by faithful flatness (Lemma \ref{prop:faithful-functor}). 

%	Take $x \in M$. Flatness implies $Ax \otimes B \hookrightarrow M \dotimes{A} B$. Note that $Ax \otimes B$ is generated by $x \otimes 1$. If $x \neq 0$ then $Ax \neq \{0\}$ and $Ax \otimes B \neq \{0\}$ since $\varphi$ is faithfully flat. This implies $x \mapsto x \otimes 1 \neq 0$.
	
	Let $\mathfrak{a} \subset A$ be a proper ideal. The previous step with $M := A/\mathfrak{a}$ implies that $A/\mathfrak{a} \to (A/\mathfrak{a}) \dotimes{A} B \simeq B/\mathfrak{a}B$ is injective, hence $\varphi^{-1}(\mathfrak{a}B) = \mathfrak{a}$.
	
	To show the surjectivity of $\varphi^\sharp$, consider a given $\mathfrak{p} \in \Spec(A)$ and form the faithfully flat ring homomorphism
	\[ \varphi_{\mathfrak{p}}: A_{\mathfrak{p}} \to B \dotimes{A} A_{\mathfrak{p}} = B_{\mathfrak{p}} \]
	by base change. The previous step implies $\varphi_{\mathfrak{p}}^{-1}(\mathfrak{p}B_{\mathfrak{p}}) = \mathfrak{p} A_{\mathfrak{p}}$, hence $\mathfrak{p}B_{\mathfrak{p}}$ is a proper ideal of $B_{\mathfrak{p}}$. Any maximal over-ideal $\mathfrak{m}_0$ of $\mathfrak{p}B_{\mathfrak{p}}$ satisfies $\varphi^{-1}_{\mathfrak{p}}(\mathfrak{m}_0) = \mathfrak{p} A_{\mathfrak{p}}$. Take $\mathfrak{m} \in \Spec(B)$ mapping to $\mathfrak{m}_0$. From the commutative diagrams
	\[\begin{tikzcd}
		B \arrow[r] & B_{\mathfrak{p}} \\
		A \arrow[u, "\varphi"] \arrow[r] & A_{\mathfrak{p}} \arrow[u, "\varphi_{\mathfrak{p}}"']
	\end{tikzcd} \qquad \begin{tikzcd}
		\Spec(B) \arrow[d, "\varphi^\sharp"'] & \Spec(B_{\mathfrak{p}}) \arrow[d, "\varphi_{\mathfrak{p}}^\sharp"] \arrow[l] \\
		\Spec(A) & \Spec(A_{\mathfrak{p}}) \arrow[l]
	\end{tikzcd}\]
	one infers $\varphi^\sharp(\mathfrak{m}) = \mathfrak{p}$.
\end{proof}

\begin{theorem}\label{prop:faithfully-flat-criterion}
	The following are equivalent for a ring homomorphism $\varphi: A \to B$.
	\begin{enumerate}[(i)]
		\item $\varphi$ is faithfully flat;
		\item $\varphi$ is flat and $\varphi^\sharp: \Spec(B) \to \Spec(A)$ is surjective;
		\item $\varphi$ is flat and for any maximal ideal $\mathfrak{p} \subset A$ there exists a maximal ideal $\mathfrak{m} \subset B$ such that $\varphi^{-1}(\mathfrak{m}) = \mathfrak{p}$.
	\end{enumerate}
\end{theorem}
\begin{proof}
	(i) $\implies$ (ii) is contained in Proposition \ref{prop:faithfully-flat-surj}. As for (ii) $\implies$ (iii), take any $\mathfrak{q} \in \Spec(B)$ that pulls back to $\mathfrak{p} \in \Spec(A)$, then any maximal over-ideal $\mathfrak{m}$ of $\mathfrak{q}$ also pulls back to $\mathfrak{p}$. To show (iii) $\implies$ (i), apply the criterion of Proposition \ref{prop:faithful-flatness-crit}: for any $\mathfrak{p} \in \MaxSpec(A)$, the existence of $\mathfrak{m} \mapsto \mathfrak{p}$ implies $\mathfrak{m} \supset \varphi(\mathfrak{p}) \cdot B = \mathfrak{p}B$, hence $\mathfrak{p}B \neq B$.
\end{proof}

The notion of flatness was first introduced by J.-P. Serre in \cite{Se55}. The surjections $\varphi^\sharp: \Spec(B) \to \Spec(A)$ (or rather their global avatars) for faithfully flat $\varphi: A \to B$ are often employed as candidates of ``coverings'' in algebraic geometry, leading up to the well-known \emph{fpqc} (faithfully flat + quasi-compact) and \emph{fppf} (faithfully flat + finitely presented) topologies in the sense of Grothendieck. They have been indispensable tools for contemporary geometers; \cite{Vi05} serves as a readable introduction to this circle of ideas.